
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Jacob
 */
public class PreviewPanel extends JPanel{
    private JLabel label;
    public void setImage(final BufferedImage image)
    {
        SwingUtilities.invokeLater(new Runnable()
        {

            @Override
            public void run() {
                if(label == null)
                {
                    label = new JLabel();
                    add(label);
                }
                label.setIcon(new ImageIcon(image));
            }
        
        });
        setPreferredSize(new Dimension(image.getWidth(), image.getHeight()));
        repaint();
    }
}
